package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-04
 * Time: 9:16
 */
public class FindOperation implements IOperation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("查找图书");
        System.out.println("输入你要查找的书名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int current = booklist.getUesdsize();
        for (int i = 0; i < current; i++) {
            Book book = booklist.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("找到了这本书");
                System.out.println(book);
                return;
            }
        }
        //i==current 没有找到这本书
        System.out.println("没有你要找的这本书");

    }

}
